package v4

import (
	"github.com/gin-gonic/gin"
	"mindonmap/models"
	"mindonmap/pkgs/e"
	"mindonmap/pkgs/setting"
	"mindonmap/pkgs/util"

	"mindonmap/validation"
	"net/http"
)

// 获取订阅信息
func Getsub(c *gin.Context) {

	var json models.UserSubscriptions
	if err := c.BindJSON(&json); err != nil {
		c.JSON(http.StatusOK, gin.H{
			"code": e.INVALID_PARAMS,
			"msg":  e.GetMsg(e.INVALID_PARAMS),
			"data": make(map[string]interface{}),
		})
		return
	}
	valid := validation.Validation{}
	valid.Required(json.UserId, "user_id").Message("不能为空")
	data := make(map[string]interface{})
	code := e.INVALID_PARAMS
	if !valid.HasErrors() {
		code = e.SUCCESS
		data["lists"] = models.GetDeviceLists(util.GetPage(c), setting.PageSize, json.UserId)
		//data["total"] = models.GetMindFlowTotal(mapsdata)
	}
	c.JSON(http.StatusOK, gin.H{
		"code": code,
		"msg":  e.GetMsg(code),
		"data": data,
	})
}
